package com.jf3q.common.service.impl;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jf3q.common.domain.Order;
import com.jf3q.common.mapper.OrderMapper;
import com.jf3q.common.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
        implements OrderService {

    @Autowired
    OrderMapper orderMapper;

    @Override
    public Page<Order> getOrderList(String memberId, String tradeState, String courseTitle, String orderBy, Page<Order> page) {
        if ("asc".equals(orderBy) || "desc".equals(orderBy)) {
            // 如果 orderBy 参数是 ASC 或 DESC，则使用 orderBy 参数，否则默认按照数据库中的顺序排序
            return orderMapper.getOrderListWithPage(memberId, tradeState, courseTitle, orderBy, page);
        } else {
            return orderMapper.getOrderListWithPage(memberId, tradeState, courseTitle, null, page);
        }
    }

    @Override
    public Order getOrder(String id) {
        return orderMapper.getOrder(id);
    }

}







